Produced by Araxis Merge on 2020-08-14 00:01:36 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Porto v3.2.3/Magento 2.x/Porto Theme/app/design/frontend/Smartwave/porto/Mageplaza_LayeredNavigation/web/js/view | layer.js | 2018-10-28 23:10:14 +0000 |
| 2 | Porto v3.2.4/Magento 2.x/Porto Theme/app/design/frontend/Smartwave/porto/Mageplaza_LayeredNavigation/web/js/view | layer.js | 2020-08-12 02:10:16 +0000 |
| Description | Between Files 1 and 2 | |
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 8 | 942 |
| Changed | 3 | 11 |
| Inserted | 4 | 33 |
| Removed | 0 | 0 |
| Whitespace | Consecutive whitespace is treated as a single space |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
| Active line-pairing rules |
No regular expressions were active.
| 1 | /** | 1 | /** | |||
| 2 | * Mageplaza | 2 | * Mageplaza | |||
| 3 | * | 3 | * | |||
| 4 | * NOTICE OF LICENSE | 4 | * NOTICE OF LICENSE | |||
| 5 | * | 5 | * | |||
| 6 | * This source file is subject to the Mageplaza.com license sliderConfig is | 6 | * This source file is subject to the Mageplaza.com license sliderConfig is | |||
| 7 | * available through the world-wide-web at this URL: | 7 | * available through the world-wide-web at this URL: | |||
| 8 | * https://www.mageplaza.com/LICENSE.txt | 8 | * https://www.mageplaza.com/LICENSE.txt | |||
| 9 | * | 9 | * | |||
| 10 | * DISCLAIMER | 10 | * DISCLAIMER | |||
| 11 | * | 11 | * | |||
| 12 | * Do not edit or add to this file if you wish to upgrade this extension to newer | 12 | * Do not edit or add to this file if you wish to upgrade this extension to newer | |||
| 13 | * version in the future. | 13 | * version in the future. | |||
| 14 | * | 14 | * | |||
| 15 | * @category Mageplaza | 15 | * @category Mageplaza | |||
| 16 | * @package Mageplaza_LayeredNavigation | 16 | * @package Mageplaza_LayeredNavigation | |||
| 17 | * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | 17 | * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | |||
| 18 | * @license https://www.mageplaza.com/LICENSE.txt | 18 | * @license https://www.mageplaza.com/LICENSE.txt | |||
| 19 | */ | 19 | */ | |||
| 20 | 20 | |||||
| 21 | define([ | 21 | define([ | |||
| 22 | 'jquery', | 22 | 'jquery', | |||
| 23 | 'Mageplaza_AjaxLayer/js/action/submit-filter', | 23 | 'Mageplaza_AjaxLayer/js/action/submit-filter', | |||
| 24 | 'Magento_Catalog/js/price-utils', | 24 | 'Magento_Catalog/js/price-utils', | |||
| 25 | 'jquery/ui', | 25 | 'jquery/ui', | |||
| 26 | 'accordion', | 26 | 'accordion', | |||
| 27 | 'productListToolbarForm' | 27 | 'productListToolbarForm' | |||
| 28 | ], function ($, submitFilterAction, ultil) { | 28 | ], function ($, submitFilterAction, ultil) { | |||
| 29 | "use strict"; | 29 | "use strict"; | |||
| 30 | var next_page = ""; | 30 | var next_page = ""; | |||
| 31 | var loading = false; | 31 | var loading = false; | |||
| 32 | var infinite_loaded_count = 0; | 32 | var infinite_loaded_count = 0; | |||
| 33 | var active = false; | 33 | var active = false; | |||
| 34 | 34 | |||||
| 35 | $.widget('mageplaza.layer', $.mage.accordion, { | 35 | $.widget('mageplaza.layer', $.mage.accordion, { | |||
| 36 | options: { | 36 | options: { | |||
| 37 | openedState: 'active', | 37 | openedState: 'active', | |||
| 38 | collapsible: true, | 38 | collapsible: true, | |||
| 39 | multipleCollapsible: true, | 39 | multipleCollapsible: true, | |||
| 40 | animate: 200, | 40 | animate: 200, | |||
| 41 | productsListSelector: '#layer-product-list', | 41 | productsListSelector: '#layer-product-list', | |||
| 42 | mobileShopbyElement: '#layered-filter-block .filter-title [data-role=title]', | 42 | mobileShopbyElement: '#layered-filter-block .filter-title [data-role=title]', | |||
| 43 | collapsibleElement: '[data-role=ln_collapsible]', | 43 | collapsibleElement: '[data-role=ln_collapsible]', | |||
| 44 | header: '[data-role=ln_title]', | 44 | header: '[data-role=ln_title]', | |||
| 45 | content: '[data-role=ln_content]', | 45 | content: '[data-role=ln_content]', | |||
| 46 | isCustomerLoggedIn: false, | 46 | isCustomerLoggedIn: false, | |||
| 47 | isAjax: true, | 47 | isAjax: true, | |||
| 48 | params: [], | 48 | params: [], | |||
| 49 | active: [], | 49 | active: [], | |||
| 50 | checkboxEl: 'input[type=checkbox]', | 50 | checkboxEl: 'input[type=checkbox]', | |||
| 51 | sliderElementPrefix: '#ln_slider_', | 51 | sliderElementPrefix: '#ln_slider_', | |||
| 52 | sliderTextElementPrefix: '#ln_slider_text_' | 52 | sliderTextElementPrefix: '#ln_slider_text_' | |||
| 53 | }, | 53 | }, | |||
| 54 | 54 | |||||
| 55 | inFinite: function() { | 55 | inFinite: function() { | |||
| 56 | var self = this; | 56 | var self = this; | |||
| 57 | next_page = ""; | 57 | next_page = ""; | |||
| 58 | if($(self.options.productsListSelector +' .infinite-loader').length > 0){ | 58 | if($(self.options.productsListSelector +' .infinite-loader').length > 0){ | |||
| 59 | active = true; | 59 | active = true; | |||
| 60 | } | 60 | } | |||
| 61 | $(".pages-items li > a.next").each(function(){ | 61 | $(".pages-items li > a.next").each(function(){ | |||
| 62 | next_page = $(this).attr("href"); | 62 | next_page = $(this).attr("href"); | |||
| 63 | }); | 63 | }); | |||
| 64 | if(!next_page){ | 64 | if(!next_page){ | |||
| 65 | $('.infinite-loader').hide(); | 65 | $('.infinite-loader').hide(); | |||
| 66 | } | 66 | } | |||
| 67 | $(".infinite-loader .btn-load-more").click(function(){ | 67 | $(".infinite-loader .btn-load-more").click(function(){ | |||
| 68 | if(!loading && next_page){ | 68 | if(!loading && next_page){ | |||
| 69 | loading = true; | 69 | loading = true; | |||
| 70 | self.ajaxInfinite(next_page); | 70 | self.ajaxInfinite(next_page); | |||
| 71 | } | 71 | } | |||
| 72 | }); | 72 | }); | |||
| 73 | }, | 73 | }, | |||
| 74 | 74 | |||||
| 75 | ajaxInfinite: function (submitUrl) { | 75 | ajaxInfinite: function (submitUrl) { | |||
| 76 | var self = this; | 76 | var self = this; | |||
| 77 | infinite_loaded_count++; | 77 | infinite_loaded_count++; | |||
| 78 | $('.infinite-loader .btn-load-more').hide(); | 78 | $('.infinite-loader .btn-load-more').hide(); | |||
| 79 | $('.infinite-loader .loading').show(); | 79 | $('.infinite-loader .loading').show(); | |||
| 80 | $.ajax({ | 80 | $.ajax({ | |||
| 81 | url: submitUrl, | 81 | url: submitUrl, | |||
| 82 | type: 'get', | 82 | type: 'get', | |||
| 83 | beforeSend: function () { | 83 | beforeSend: function () { | |||
| 84 | $('.infinite-loader .btn-load-more').hide(); | 84 | $('.infinite-loader .btn-load-more').hide(); | |||
| 85 | $('.infinite-loader .loading').show(); | 85 | $('.infinite-loader .loading').show(); | |||
| 86 | }, | 86 | }, | |||
| 87 | success: function (res) { | 87 | success: function (res) { | |||
| 88 | loading = false; | 88 | loading = false; | |||
| 89 | var $products = $(res.products); | 89 | var $products = $(res.products); | |||
| 90 | if (res.backUrl) { | 90 | if (res.backUrl) { | |||
| 91 | window.location = res.backUrl; | 91 | window.location = res.backUrl; | |||
| 92 | return; | 92 | return; | |||
| 93 | } | 93 | } | |||
| 94 | if($products){ | 94 | if($products){ | |||
| 95 | $products.each(function(i,el){ | 95 | $products.each(function(i,el){ | |||
| 96 | if($(el).hasClass('products-grid')){ | 96 | if($(el).hasClass('products-grid')){ | |||
| 97 | var items_grid = $(this).find('.product-items .item'); | 97 | var items_grid = $(this).find('.product-items .item'); | |||
| 98 | $(self.options.productsListSelector + ' .products.wrapper .product-items').append(items_grid); | 98 | $(self.options.productsListSelector + ' .products.wrapper .product-items').append(items_grid); | |||
| 99 | $(self.options.productsListSelector).trigger('contentUpdated'); | 99 | $(self.options.productsListSelector).trigger('contentUpdated'); | |||
| 100 | } | 100 | } | |||
| 101 | if($(el).hasClass('products-list')){ | 101 | if($(el).hasClass('products-list')){ | |||
| 102 | var items_list = $(this).find('.product-items .item'); | 102 | var items_list = $(this).find('.product-items .item'); | |||
| 103 | $(self.options.productsListSelector + ' .products.wrapper .product-items').append(items_list); | 103 | $(self.options.productsListSelector + ' .products.wrapper .product-items').append(items_list); | |||
| 104 | $(self.options.productsListSelector).trigger('contentUpdated'); | 104 | $(self.options.productsListSelector).trigger('contentUpdated'); | |||
| 105 | } | 105 | } | |||
| 106 | if($(el).hasClass('toolbar-products')){ | 106 | if($(el).hasClass('toolbar-products')){ | |||
| 107 | if($(this).find('.pages a.next').length > 0){ | 107 | if($(this).find('.pages a.next').length > 0){ | |||
| 108 | $(self.options.productsListSelector + ' .pages a.next').attr('href', $(this).find('.pages a.next').attr('href')); | 108 | $(self.options.productsListSelector + ' .pages a.next').attr('href', $(this).find('.pages a.next').attr('href')); | |||
| 109 | }else{ | 109 | }else{ | |||
| 110 | $(self.options.productsListSelector + ' .pages a.next').remove(); | 110 | $(self.options.productsListSelector + ' .pages a.next').remove(); | |||
| 111 | } | 111 | } | |||
| 112 | } | 112 | } | |||
| 113 | }); | 113 | }); | |||
| 114 | if($("form[data-role=tocart-form]").length > 0) { | 114 | if($("form[data-role=tocart-form]").length > 0) { | |||
| 115 | $("form[data-role=tocart-form]").catalogAddToCart(); | 115 | $("form[data-role=tocart-form]").catalogAddToCart(); | |||
| 116 | } | 116 | } | |||
| 117 | $('.main .products.grid .product-items li.product-item:nth-child(2n)').addClass('nth-child-2n'); | 117 | $('.main .products.grid .product-items li.product-item:nth-child(2n)').addClass('nth-child-2n'); | |||
| 118 | $('.main .products.grid .product-items li.product-item:nth-child(2n+1)').addClass('nth-child-2np1'); | 118 | $('.main .products.grid .product-items li.product-item:nth-child(2n+1)').addClass('nth-child-2np1'); | |||
| 119 | $('.main .products.grid .product-items li.product-item:nth-child(3n)').addClass('nth-child-3n'); | 119 | $('.main .products.grid .product-items li.product-item:nth-child(3n)').addClass('nth-child-3n'); | |||
| 120 | $('.main .products.grid .product-items li.product-item:nth-child(3n+1)').addClass('nth-child-3np1'); | 120 | $('.main .products.grid .product-items li.product-item:nth-child(3n+1)').addClass('nth-child-3np1'); | |||
| 121 | $('.main .products.grid .product-items li.product-item:nth-child(4n)').addClass('nth-child-4n'); | 121 | $('.main .products.grid .product-items li.product-item:nth-child(4n)').addClass('nth-child-4n'); | |||
| 122 | $('.main .products.grid .product-items li.product-item:nth-child(4n+1)').addClass('nth-child-4np1'); | 122 | $('.main .products.grid .product-items li.product-item:nth-child(4n+1)').addClass('nth-child-4np1'); | |||
| 123 | $('.main .products.grid .product-items li.product-item:nth-child(5n)').addClass('nth-child-5n'); | 123 | $('.main .products.grid .product-items li.product-item:nth-child(5n)').addClass('nth-child-5n'); | |||
| 124 | $('.main .products.grid .product-items li.product-item:nth-child(5n+1)').addClass('nth-child-5np1'); | 124 | $('.main .products.grid .product-items li.product-item:nth-child(5n+1)').addClass('nth-child-5np1'); | |||
| 125 | $('.main .products.grid .product-items li.product-item:nth-child(6n)').addClass('nth-child-6n'); | 125 | $('.main .products.grid .product-items li.product-item:nth-child(6n)').addClass('nth-child-6n'); | |||
| 126 | $('.main .products.grid .product-items li.product-item:nth-child(6n+1)').addClass('nth-child-6np1'); | 126 | $('.main .products.grid .product-items li.product-item:nth-child(6n+1)').addClass('nth-child-6np1'); | |||
| 127 | $('.main .products.grid .product-items li.product-item:nth-child(7n)').addClass('nth-child-7n'); | 127 | $('.main .products.grid .product-items li.product-item:nth-child(7n)').addClass('nth-child-7n'); | |||
| 128 | $('.main .products.grid .product-items li.product-item:nth-child(7n+1)').addClass('nth-child-7np1'); | 128 | $('.main .products.grid .product-items li.product-item:nth-child(7n+1)').addClass('nth-child-7np1'); | |||
| 129 | $('.main .products.grid .product-items li.product-item:nth-child(8n)').addClass('nth-child-8n'); | 129 | $('.main .products.grid .product-items li.product-item:nth-child(8n)').addClass('nth-child-8n'); | |||
| 130 | $('.main .products.grid .product-items li.product-item:nth-child(8n+1)').addClass('nth-child-8np1'); | 130 | $('.main .products.grid .product-items li.product-item:nth-child(8n+1)').addClass('nth-child-8np1'); | |||
| 131 | var hist = submitUrl; | 131 | var hist = submitUrl; | |||
| 132 | if(submitUrl.indexOf("p=") > -1){ | 132 | if(submitUrl.indexOf("p=") > -1){ | |||
| 133 | var len = submitUrl.length-submitUrl.indexOf("p="); | 133 | var len = submitUrl.length-submitUrl.indexOf("p="); | |||
| 134 | var str_temp = submitUrl.substr(submitUrl.indexOf("p="),len); | 134 | var str_temp = submitUrl.substr(submitUrl.indexOf("p="),len); | |||
| 135 | var page_param = ""; | 135 | var page_param = ""; | |||
| 136 | if(str_temp.indexOf("&") == -1){ | 136 | if(str_temp.indexOf("&") == -1){ | |||
| 137 | page_param = str_temp; | 137 | page_param = str_temp; | |||
| 138 | } else { | 138 | } else { | |||
| 139 | page_param = str_temp.substr(0,str_temp.indexOf("&")); | 139 | page_param = str_temp.substr(0,str_temp.indexOf("&")); | |||
| 140 | } | 140 | } | |||
| 141 | hist = submitUrl.replace(page_param, ""); | 141 | hist = submitUrl.replace(page_param, ""); | |||
| 142 | } | 142 | } | |||
| 143 | if (typeof window.history.pushState === 'function') { | 143 | if (typeof window.history.pushState === 'function') { | |||
| 144 | window.history.pushState({url: hist}, '', hist); | 144 | window.history.pushState({url: hist}, '', hist); | |||
| 145 | } | 145 | } | |||
| 146 | if(typeof enable_quickview != 'undefined' && enable_quickview == true) { | 146 | if(typeof enable_quickview != 'undefined' && enable_quickview == true) { | |||
| 147 | requirejs(['jquery', 'weltpixel_quickview' ], | 147 | requirejs(['jquery', 'weltpixel_quickview' ], | |||
| 148 | function($, quickview) { | 148 | function($, quickview) { | |||
| 149 | $('.weltpixel-quickview').off('click').on('click', function() { | 149 | $('.weltpixel-quickview').off('click').on('click', function() { | |||
| 150 | var prodUrl = $(this).attr('data-quickview-url'); | 150 | var prodUrl = $(this).attr('data-quickview-url'); | |||
| 151 | if (prodUrl.length) { | 151 | if (prodUrl.length) { | |||
| 152 | quickview.displayContent(prodUrl); | 152 | quickview.displayContent(prodUrl); | |||
| 153 | } | 153 | } | |||
| 154 | }); | 154 | }); | |||
| 155 | }); | 155 | }); | |||
| 156 | } | 156 | } | |||
| 157 | $(".products-grid .weltpixel-quickview").each(function(){ | 157 | $(".products-grid .weltpixel-quickview").each(function(){ | |||
| 158 | $(this).appendTo($(this).parent().parent().children(".product-item-photo")); | 158 | $(this).appendTo($(this).parent().parent().children(".product-item-photo")); | |||
| 159 | }); | 159 | }); | |||
| 160 | $("#layer-product-list img.porto-lazyload:not(.porto-lazyload-loaded)").lazyload({effect:"fadeIn"}); | 160 | $("#layer-product-list img.porto-lazyload:not(.porto-lazyload-loaded)").lazyload({effect:"fadeIn"}); | |||
| 161 | if ($('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').length) { | 161 | if ($('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').length) { | |||
| 162 | $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('initialized.owl.carousel', function() { | 162 | $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('initialized.owl.carousel', function() { | |||
| 163 | $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear'); | 163 | $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear'); | |||
| 164 | }); | 164 | }); | |||
| 165 | $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('changed.owl.carousel', function() { | 165 | $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('changed.owl.carousel', function() { | |||
| 166 | $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear'); | 166 | $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear'); | |||
| 167 | }); | 167 | }); | |||
| 168 | } | 168 | } | |||
| 169 | self.initWishlistCompare(); | |||||
| 169 | next_page = ""; | 170 | next_page = ""; | |||
| 170 | $(".pages-items li > a.next").each(function(){ | 171 | $(".pages-items li > a.next").each(function(){ | |||
| 171 | next_page = $(this).attr("href"); | 172 | next_page = $(this).attr("href"); | |||
| 172 | }); | 173 | }); | |||
| 173 | $('.infinite-loader .loading').hide(); | 174 | $('.infinite-loader .loading').hide(); | |||
| 174 | if(next_page){ | 175 | if(next_page){ | |||
| 175 | $('.infinite-loader .btn-load-more').show(); | 176 | $('.infinite-loader .btn-load-more').show(); | |||
| 176 | $(".infinite-loader .btn-load-more").unbind("click").click(function(){ | 177 | $(".infinite-loader .btn-load-more").unbind("click").click(function(){ | |||
| 177 | if(!loading && next_page){ | 178 | if(!loading && next_page){ | |||
| 178 | loading = true; | 179 | loading = true; | |||
| 179 | self.ajaxInfinite(next_page); | 180 | self.ajaxInfinite(next_page); | |||
| 180 | } | 181 | } | |||
| 181 | }); | 182 | }); | |||
| 182 | } | 183 | } | |||
| 183 | } | 184 | } | |||
| 184 | 185 | |||||
| 185 | }, | 186 | }, | |||
| 186 | error: function () { | 187 | error: function () { | |||
| 187 | window.location.reload(); | 188 | window.location.reload(); | |||
| 188 | } | 189 | } | |||
| 189 | }); | 190 | }); | |||
| 190 | }, | 191 | }, | |||
| 191 | 192 | |||||
| 192 | _create: function () { | 193 | _create: function () { | |||
| 193 | this.initActiveItems(); | 194 | this.initActiveItems(); | |||
| 194 | 195 | |||||
| 195 | this._super(); | 196 | this._super(); | |||
| 196 | 197 | |||||
| 197 | this.initProductListUrl(); | 198 | this.initProductListUrl(); | |||
| 198 | this.initObserve(); | 199 | this.initObserve(); | |||
| 199 | this.initSlider(); | 200 | this.initSlider(); | |||
| 200 | this.initWishlistCompare(); | 201 | this.initWishlistCompare(); | |||
| 202 | this.selectedAttr(); | |||||
| 201 | }, | 203 | }, | |||
| 202 | 204 | |||||
| 203 | initActiveItems: function () { | 205 | initActiveItems: function () { | |||
| 204 | var layerActives = this.options.active, | 206 | var layerActives = this.options.active, | |||
| 205 | actives = []; | 207 | actives = []; | |||
| 206 | 208 | |||||
| 207 | if (typeof window.layerActiveTabs !== 'undefined') { | 209 | if (typeof window.layerActiveTabs !== 'undefined') { | |||
| 208 | layerActives = window.layerActiveTabs; | 210 | layerActives = window.layerActiveTabs; | |||
| 209 | } | 211 | } | |||
| 210 | if (layerActives.length) { | 212 | if (layerActives.length) { | |||
| 211 | this.element.find('.filter-options-item').each(function (index) { | 213 | this.element.find('.filter-options-item').each(function (index) { | |||
| 212 | if (~$.inArray($(this).attr('attribute'), layerActives)) { | 214 | if (~$.inArray($(this).attr('attribute'), layerActives)) { | |||
| 213 | actives.push(index); | 215 | actives.push(index); | |||
| 214 | } | 216 | } | |||
| 215 | }); | 217 | }); | |||
| 216 | } | 218 | } | |||
| 217 | 219 | |||||
| 218 | this.options.active = actives; | 220 | this.options.active = actives; | |||
| 219 | 221 | |||||
| 220 | return this; | 222 | return this; | |||
| 221 | }, | 223 | }, | |||
| 222 | 224 | |||||
| 223 | initProductListUrl: function () { | 225 | initProductListUrl: function () { | |||
| 224 | var isProcessToolbar = false, | 226 | var isProcessToolbar = false, | |||
| 225 | isAjax = this.options.isAjax; | 227 | isAjax = this.options.isAjax; | |||
| 226 | $.mage.productListToolbarForm.prototype.changeUrl = function (paramName, paramValue, defaultValue) { | 228 | $.mage.productListToolbarForm.prototype.changeUrl = function (paramName, paramValue, defaultValue) { | |||
| 227 | if (isProcessToolbar) { | 229 | if (isProcessToolbar) { | |||
| 228 | return; | 230 | return; | |||
| 229 | } | 231 | } | |||
| 230 | if (isAjax) { | 232 | if (isAjax) { | |||
| 231 | isProcessToolbar = true; | 233 | isProcessToolbar = true; | |||
| 232 | } | 234 | } | |||
| 233 | 235 | |||||
| 234 | var urlPaths = this.options.url.split('?'), | 236 | var urlPaths = this.options.url.split('?'), | |||
| 235 | baseUrl = urlPaths[0], | 237 | baseUrl = urlPaths[0], | |||
| 236 | urlParams = urlPaths[1] ? urlPaths[1].split('&') : [], | 238 | urlParams = urlPaths[1] ? urlPaths[1].split('&') : [], | |||
| 237 | paramData = {}, | 239 | paramData = {}, | |||
| 238 | parameters; | 240 | parameters; | |||
| 239 | for (var i = 0; i < urlParams.length; i++) { | 241 | for (var i = 0; i < urlParams.length; i++) { | |||
| 240 | parameters = urlParams[i].split('='); | 242 | parameters = urlParams[i].split('='); | |||
| 241 | paramData[parameters[0]] = parameters[1] !== undefined | 243 | paramData[parameters[0]] = parameters[1] !== undefined | |||
| 242 | ? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20')) | 244 | ? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20')) | |||
| 243 | : ''; | 245 | : ''; | |||
| 244 | } | 246 | } | |||
| 245 | paramData[paramName] = paramValue; | 247 | paramData[paramName] = paramValue; | |||
| 246 | if (paramValue === defaultValue) { | 248 | if (paramValue === defaultValue) { | |||
| 247 | delete paramData[paramName]; | 249 | delete paramData[paramName]; | |||
| 248 | } | 250 | } | |||
| 249 | paramData = $.param(paramData); | 251 | paramData = $.param(paramData); | |||
| 250 | if (isAjax) { | 252 | if (isAjax) { | |||
| 251 | submitFilterAction(baseUrl + (paramData.length ? '?' + paramData : '')); | 253 | submitFilterAction(baseUrl + (paramData.length ? '?' + paramData : '')); | |||
| 252 | } | 254 | } else location.href = baseUrl + (paramData.length ? '?' + paramData : ''); | |||
| 253 | | |||||
| 254 | } | 255 | } | |||
| 255 | }, | 256 | }, | |||
| 256 | 257 | |||||
| 257 | initObserve: function () { | 258 | initObserve: function () { | |||
| 258 | var self = this; | 259 | var self = this; | |||
| 259 | var isAjax = this.options.isAjax; | 260 | var isAjax = this.options.isAjax; | |||
| 260 | infinite_loaded_count = 0; | 261 | infinite_loaded_count = 0; | |||
| 261 | 262 | |||||
| 263 | // fix browser back, forward button | |||||
| 264 | if (typeof window.history.replaceState === "function") { | |||||
| 265 | window.history.replaceState({url: document.URL}, document.title); | |||||
| 266 | ||||||
| 267 | setTimeout(function () { | |||||
| 268 | window.onpopstate = function (e) { | |||||
| 269 | if (e.state) { | |||||
| 270 | submitFilterAction(e.state.url, 1); | |||||
| 271 | } | |||||
| 272 | }; | |||||
| 273 | }, 0) | |||||
| 274 | } | |||||
| 275 | ||||||
| 262 | var pageElements = $('#layer-product-list').find('.pages a'); | 276 | var pageElements = $('#layer-product-list').find('.pages a'); | |||
| 263 | pageElements.each(function () { | 277 | pageElements.each(function () { | |||
| 264 | var el = $(this), | 278 | var el = $(this), | |||
| 265 | link = self.checkUrl(el.prop('href')); | 279 | link = self.checkUrl(el.prop('href')); | |||
| 266 | if (!link) { | 280 | if (!link) { | |||
| 267 | return; | 281 | return; | |||
| 268 | } | 282 | } | |||
| 269 | 283 | |||||
| 270 | el.bind('click', function (e) { | 284 | el.bind('click', function (e) { | |||
| 271 | e.stopPropagation(); | 285 | e.stopPropagation(); | |||
| 272 | e.preventDefault(); | 286 | e.preventDefault(); | |||
| 273 | if (isAjax) { | 287 | if (isAjax) { | |||
| 274 | submitFilterAction(link); | 288 | submitFilterAction(link); | |||
| 275 | } | 289 | } | |||
| 276 | else location.href = link; | 290 | else location.href = link; | |||
| 277 | }) | 291 | }) | |||
| 278 | }); | 292 | }); | |||
| 279 | 293 | |||||
| 280 | var currentElements = this.element.find('.filter-current a, .filter-actions a'); | 294 | var currentElements = this.element.find('.filter-current a, .filter-actions a'); | |||
| 281 | currentElements.each(function (index) { | 295 | currentElements.each(function (index) { | |||
| 282 | var el = $(this), | 296 | var el = $(this), | |||
| 283 | link = self.checkUrl(el.prop('href')); | 297 | link = self.checkUrl(el.prop('href')); | |||
| 284 | if (!link) { | 298 | if (!link) { | |||
| 285 | return; | 299 | return; | |||
| 286 | } | 300 | } | |||
| 287 | 301 | |||||
| 288 | el.bind('click', function (e) { | 302 | el.bind('click', function (e) { | |||
| 289 | e.stopPropagation(); | 303 | e.stopPropagation(); | |||
| 290 | e.preventDefault(); | 304 | e.preventDefault(); | |||
| 291 | if (isAjax) { | 305 | if (isAjax) { | |||
| 292 | submitFilterAction(link); | 306 | submitFilterAction(link); | |||
| 293 | } | 307 | } | |||
| 294 | else location.href = link; | 308 | else location.href = link; | |||
| 295 | }); | 309 | }); | |||
| 296 | }); | 310 | }); | |||
| 297 | 311 | |||||
| 298 | var optionElements = this.element.find('.filter-options a'); | 312 | var optionElements = this.element.find('.filter-options a'); | |||
| 299 | optionElements.each(function (index) { | 313 | optionElements.each(function (index) { | |||
| 300 | var el = $(this), | 314 | var el = $(this), | |||
| 301 | link = self.checkUrl(el.prop('href')); | 315 | link = self.checkUrl(el.prop('href')); | |||
| 302 | if (!link) { | 316 | if (!link) { | |||
| 303 | return; | 317 | return; | |||
| 304 | } | 318 | } | |||
| 305 | 319 | |||||
| 306 | el.bind('click', function (e) { | 320 | el.bind('click', function (e) { | |||
| 307 | if (el.hasClass('swatch-option-link-layered')) { | 321 | if (el.hasClass('swatch-option-link-layered')) { | |||
| 308 | self.selectSwatchOption(el); | 322 | self.selectSwatchOption(el); | |||
| 309 | } else { | 323 | } else { | |||
| 310 | var checkboxEl = el.siblings(self.options.checkboxEl); | 324 | var checkboxEl = el.siblings(self.options.checkboxEl); | |||
| 311 | checkboxEl.prop('checked', !checkboxEl.prop('checked')); | 325 | checkboxEl.prop('checked', !checkboxEl.prop('checked')); | |||
| 312 | } | 326 | } | |||
| 313 | 327 | |||||
| 314 | e.stopPropagation(); | 328 | e.stopPropagation(); | |||
| 315 | e.preventDefault(); | 329 | e.preventDefault(); | |||
| 316 | self.ajaxSubmit(link); | 330 | self.ajaxSubmit(link); | |||
| 317 | }); | 331 | }); | |||
| 318 | 332 | |||||
| 319 | var checkbox = el.siblings(self.options.checkboxEl); | 333 | var checkbox = el.siblings(self.options.checkboxEl); | |||
| 320 | checkbox.bind('click', function (e) { | 334 | checkbox.bind('click', function (e) { | |||
| 321 | e.stopPropagation(); | 335 | e.stopPropagation(); | |||
| 322 | self.ajaxSubmit(link); | 336 | self.ajaxSubmit(link); | |||
| 323 | }); | 337 | }); | |||
| 324 | }); | 338 | }); | |||
| 325 | 339 | |||||
| 326 | var swatchElements = this.element.find('.swatch-attribute'); | 340 | var swatchElements = this.element.find('.swatch-attribute'); | |||
| 327 | swatchElements.each(function (index) { | 341 | swatchElements.each(function (index) { | |||
| 328 | var el = $(this); | 342 | var el = $(this); | |||
| 329 | var attCode = el.attr('attribute-code'); | 343 | var attCode = el.attr('attribute-code'); | |||
| 330 | if (attCode) { | 344 | if (attCode) { | |||
| 331 | if (self.options.params.hasOwnProperty(attCode)) { | 345 | if (self.options.params.hasOwnProperty(attCode)) { | |||
| 332 | var attValues = self.options.params[attCode].split(","); | 346 | var attValues = self.options.params[attCode].split(","); | |||
| 333 | var swatchOptions = el.find('.swatch-option'); | 347 | var swatchOptions = el.find('.swatch-option'); | |||
| 334 | swatchOptions.each(function (option) { | 348 | swatchOptions.each(function (option) { | |||
| 335 | var elOption = $(this); | 349 | var elOption = $(this); | |||
| 336 | if ($.inArray(elOption.attr('option-id'), attValues) !== -1) { | 350 | if ($.inArray(elOption.attr('option-id'), attValues) !== -1) { | |||
| 337 | elOption.addClass('selected'); | 351 | elOption.addClass('selected'); | |||
| 338 | } | 352 | } | |||
| 339 | }); | 353 | }); | |||
| 340 | } | 354 | } | |||
| 341 | } | 355 | } | |||
| 342 | }); | 356 | }); | |||
| 343 | 357 | |||||
| 344 | if(typeof enable_quickview != 'undefined' && enable_quickview == true) { | 358 | if(typeof enable_quickview != 'undefined' && enable_quickview == true) { | |||
| 345 | requirejs(['jquery', 'weltpixel_quickview' ], | 359 | requirejs(['jquery', 'weltpixel_quickview' ], | |||
| 346 | function($, quickview) { | 360 | function($, quickview) { | |||
| 347 | $('.weltpixel-quickview').off('click').on('click', function() { | 361 | $('.weltpixel-quickview').off('click').on('click', function() { | |||
| 348 | var prodUrl = $(this).attr('data-quickview-url'); | 362 | var prodUrl = $(this).attr('data-quickview-url'); | |||
| 349 | if (prodUrl.length) { | 363 | if (prodUrl.length) { | |||
| 350 | quickview.displayContent(prodUrl); | 364 | quickview.displayContent(prodUrl); | |||
| 351 | } | 365 | } | |||
| 352 | }); | 366 | }); | |||
| 353 | }); | 367 | }); | |||
| 354 | } | 368 | } | |||
| 355 | 369 | |||||
| 356 | $(".products-grid .weltpixel-quickview").each(function(){ | 370 | $(".products-grid .weltpixel-quickview").each(function(){ | |||
| 357 | $(this).appendTo($(this).parents('.product-item-info').children(".product-item-photo")); | 371 | $(this).appendTo($(this).parents('.product-item-info').children(".product-item-photo")); | |||
| 358 | }); | 372 | }); | |||
| 359 | $("#layer-product-list img.porto-lazyload:not(.porto-lazyload-loaded)").lazyload({effect:"fadeIn"}); | 373 | $("#layer-product-list img.porto-lazyload:not(.porto-lazyload-loaded)").lazyload({effect:"fadeIn"}); | |||
| 360 | if ($('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').length) { | 374 | if ($('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').length) { | |||
| 361 | $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('changed.owl.carousel', function() { | 375 | $('#layer-product-list .porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('changed.owl.carousel', function() { | |||
| 362 | $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear'); | 376 | $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear'); | |||
| 363 | }); | 377 | }); | |||
| 364 | } | 378 | } | |||
| 365 | if(isAjax) { | 379 | if(isAjax) { | |||
| 366 | self.inFinite(); | 380 | self.inFinite(); | |||
| 367 | }else{ | 381 | }else{ | |||
| 368 | $('.infinite-loader').hide(); | 382 | $('.infinite-loader').hide(); | |||
| 369 | } | 383 | } | |||
| 370 | 384 | |||||
| 371 | }, | 385 | }, | |||
| 372 | 386 | |||||
| 373 | selectSwatchOption: function (el) { | 387 | selectSwatchOption: function (el) { | |||
| 374 | var childEl = el.find('.swatch-option'); | 388 | var childEl = el.find('.swatch-option'); | |||
| 375 | if (childEl.hasClass('selected')) { | 389 | if (childEl.hasClass('selected')) { | |||
| 376 | childEl.removeClass('selected'); | 390 | childEl.removeClass('selected'); | |||
| 377 | } else { | 391 | } else { | |||
| 378 | childEl.addClass('selected'); | 392 | childEl.addClass('selected'); | |||
| 379 | } | 393 | } | |||
| 380 | }, | 394 | }, | |||
| 381 | 395 | |||||
| 382 | initSlider: function () { | 396 | initSlider: function () { | |||
| 383 | var self = this, | 397 | var self = this, | |||
| 384 | slider = this.options.slider; | 398 | slider = this.options.slider; | |||
| 385 | 399 | |||||
| 386 | for (var code in slider) { | 400 | for (var code in slider) { | |||
| 387 | if (slider.hasOwnProperty(code)) { | 401 | if (slider.hasOwnProperty(code)) { | |||
| 388 | var sliderConfig = slider[code], | 402 | var sliderConfig = slider[code], | |||
| 389 | sliderElement = self.element.find(this.options.sliderElementPrefix + code), | 403 | sliderElement = self.element.find(this.options.sliderElementPrefix + code), | |||
| 390 | priceFormat = sliderConfig.hasOwnProperty('priceFormat') ? JSON.parse(sliderConfig.priceFormat) : null; | 404 | priceFormat = sliderConfig.hasOwnProperty('priceFormat') ? JSON.parse(sliderConfig.priceFormat) : null; | |||
| 391 | 405 | |||||
| 392 | if (sliderElement.length) { | 406 | if (sliderElement.length) { | |||
| 393 | sliderElement.slider({ | 407 | sliderElement.slider({ | |||
| 394 | range: true, | 408 | range: true, | |||
| 395 | min: sliderConfig.minValue, | 409 | min: sliderConfig.minValue, | |||
| 396 | max: sliderConfig.maxValue, | 410 | max: sliderConfig.maxValue, | |||
| 397 | values: [sliderConfig.selectedFrom, sliderConfig.selectedTo], | 411 | values: [sliderConfig.selectedFrom, sliderConfig.selectedTo], | |||
| 398 | slide: function (event, ui) { | 412 | slide: function (event, ui) { | |||
| 399 | self.displaySliderText(code, ui.values[0], ui.values[1], priceFormat); | 413 | self.displaySliderText(code, ui.values[0], ui.values[1], priceFormat); | |||
| 400 | }, | 414 | }, | |||
| 401 | change: function (event, ui) { | 415 | change: function (event, ui) { | |||
| 402 | self.ajaxSubmit(self.getSliderUrl(sliderConfig.ajaxUrl, ui.values[0], ui.values[1])); | 416 | self.ajaxSubmit(self.getSliderUrl(sliderConfig.ajaxUrl, ui.values[0], ui.values[1])); | |||
| 403 | } | 417 | } | |||
| 404 | }); | 418 | }); | |||
| 405 | } | 419 | } | |||
| 406 | self.displaySliderText(code, sliderConfig.selectedFrom, sliderConfig.selectedTo, priceFormat); | 420 | self.displaySliderText(code, sliderConfig.selectedFrom, sliderConfig.selectedTo, priceFormat); | |||
| 407 | } | 421 | } | |||
| 408 | } | 422 | } | |||
| 409 | }, | 423 | }, | |||
| 410 | 424 | |||||
| 411 | displaySliderText: function (code, from, to, format) { | 425 | displaySliderText: function (code, from, to, format) { | |||
| 412 | var textElement = this.element.find(this.options.sliderTextElementPrefix + code); | 426 | var textElement = this.element.find(this.options.sliderTextElementPrefix + code); | |||
| 413 | if (textElement.length) { | 427 | if (textElement.length) { | |||
| 414 | if (format !== null) { | 428 | if (format !== null) { | |||
| 415 | from = this.formatPrice(from, format); | 429 | from = this.formatPrice(from, format); | |||
| 416 | to = this.formatPrice(to, format); | 430 | to = this.formatPrice(to, format); | |||
| 417 | } | 431 | } | |||
| 418 | 432 | |||||
| 419 | textElement.html(from + ' - ' + to); | 433 | textElement.html(from + ' - ' + to); | |||
| 420 | } | 434 | } | |||
| 421 | }, | 435 | }, | |||
| 422 | 436 | |||||
| 423 | getSliderUrl: function (url, from, to) { | 437 | getSliderUrl: function (url, from, to) { | |||
| 424 | return url.replace('from-to', from + '-' + to); | 438 | return url.replace('from-to', from + '-' + to); | |||
| 425 | }, | 439 | }, | |||
| 426 | 440 | |||||
| 427 | formatPrice: function (value, format) { | 441 | formatPrice: function (value, format) { | |||
| 428 | return ultil.formatPrice(value, format); | 442 | return ultil.formatPrice(value, format); | |||
| 429 | }, | 443 | }, | |||
| 430 | 444 | |||||
| 431 | ajaxSubmit: function (submitUrl) { | 445 | ajaxSubmit: function (submitUrl) { | |||
| 432 | var isAjax = this.options.isAjax; | 446 | var isAjax = this.options.isAjax; | |||
| 433 | this.element.find(this.options.mobileShopbyElement).trigger('click'); | 447 | this.element.find(this.options.mobileShopbyElement).trigger('click'); | |||
| 434 | 448 | |||||
| 435 | if (isAjax) { | 449 | if (isAjax) { | |||
| 436 | return submitFilterAction(submitUrl); | 450 | return submitFilterAction(submitUrl); | |||
| 437 | } | 451 | } | |||
| 438 | location.href = submitUrl; | 452 | location.href = submitUrl; | |||
| 439 | }, | 453 | }, | |||
| 440 | 454 | |||||
| 441 | checkUrl: function (url) { | 455 | checkUrl: function (url) { | |||
| 442 | var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/; | 456 | var regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/; | |||
| 443 | 457 | |||||
| 444 | return regex.test(url) ? url : null; | 458 | return regex.test(url) ? url : null; | |||
| 445 | }, | 459 | }, | |||
| 446 | 460 | |||||
| 447 | //Handling 'add to wishlist' & 'add to compare' event | 461 | //Handling 'add to wishlist' & 'add to compare' event | |||
| 448 | initWishlistCompare: function () { | 462 | initWishlistCompare: function () { | |||
| 449 | var isAjax = this.options.isAjax; | 463 | var isAjax = this.options.isAjax; | |||
| 450 | var isCustomerLoggedIn = this.options.isCustomerLoggedIn, | 464 | var isCustomerLoggedIn = this.options.isCustomerLoggedIn, | |||
| 451 | elClass = 'a.action.tocompare' + (isCustomerLoggedIn ? ',a.action.towishlist' : ''); | 465 | elClass = 'a.action.tocompare' + (isCustomerLoggedIn ? ',a.action.towishlist' : ''); | |||
| 452 | $(elClass).each(function () { | 466 | $(elClass).each(function () { | |||
| 453 | var el = $(this); | 467 | var el = $(this); | |||
| 454 | $(el).bind('click', function (e) { | 468 | $(el).bind('click', function (e) { | |||
| 455 | var dataPost = $(el).data('post'), | 469 | var dataPost = $(el).data('post'), | |||
| 456 | formKey = $('input[name="form_key"]').val(); | 470 | formKey = $('input[name="form_key"]').val(); | |||
| 457 | if (formKey) { | 471 | if (formKey) { | |||
| 458 | dataPost.data.form_key = formKey; | 472 | dataPost.data.form_key = formKey; | |||
| 459 | } | 473 | } | |||
| 460 | 474 | |||||
| 461 | var paramData = $.param(dataPost.data), | 475 | var paramData = $.param(dataPost.data), | |||
| 462 | url = dataPost.action + (paramData.length ? '?' + paramData : ''); | 476 | url = dataPost.action + (paramData.length ? '?' + paramData : ''); | |||
| 463 | 477 | |||||
| 464 | e.stopPropagation(); | 478 | e.stopPropagation(); | |||
| 465 | e.preventDefault(); | 479 | e.preventDefault(); | |||
| 466 | | 480 | ||||
| 481 | if (isAjax && el.hasClass('towishlist')) { | |||||
| 482 | submitFilterAction(url, true); | |||||
| 483 | } else if (isAjax) { | |||||
| 467 | submitFilterAction(url); | 484 | submitFilterAction(url); | |||
| 468 | } | 485 | } else location.href = url; | |||
| 469 | | |||||
| 470 | }); | 486 | }); | |||
| 471 | }) | 487 | }) | |||
| 488 | }, | |||||
| 489 | ||||||
| 490 | //Selected attribute color after page load. | |||||
| 491 | selectedAttr: function () { | |||||
| 492 | var filterCurrent = $('.layered-filter-block-container .filter-current .items .item .filter-value'); | |||||
| 493 | ||||||
| 494 | filterCurrent.each(function(){ | |||||
| 495 | var el = $(this), | |||||
| 496 | colorLabel = el.html(), | |||||
| 497 | colorAttr = $('.filter-options .filter-options-item .color .swatch-option-link-layered .swatch-option'); | |||||
| 498 | ||||||
| 499 | colorAttr.each(function(){ | |||||
| 500 | var elA = $(this); | |||||
| 501 | if(elA.attr('data-option-label') === colorLabel && !elA.hasClass('selected')){ | |||||
| 502 | elA.addClass('selected'); | |||||
| 503 | } | |||||
| 504 | }); | |||||
| 505 | }); | |||||
| 472 | } | 506 | } | |||
| 473 | }); | 507 | }); | |||
| 474 | 508 | |||||
| 475 | return $.mageplaza.layer; | 509 | return $.mageplaza.layer; | |||
| 476 | }); | 510 | }); |
Araxis Merge (but not the data content of this report) is Copyright © 1993–2019 Araxis Ltd (www.araxis.com). All rights reserved.